<template>
	<view>
		<cu-navbar :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">支付</block>
		</cu-navbar>
		<view class="cu-list menu margin-top">
			<view class="cu-item">
				<view class="content"><text class="text-grey">订单类型</text></view>
				<view class="action"><text class="text-grey text-sm">购买订单</text></view>
			</view>
			<view class="cu-item">
				<view class="content"><text class="text-grey">订单编号</text></view>
				<view class="action"><text class="text-grey text-sm" v-text="orderId"></text></view>
			</view>
			<view class="cu-item">
				<view class="content"><text class="text-grey">支付金额</text></view>
				<view class="action"><text class="text-mauve" v-text="order.amount ? order.amount : 0"></text></view>
			</view>
		</view>
		<!-- #ifdef H5 -->
		<payments-by-h5 :orderId="orderId"></payments-by-h5>
		<!-- #endif -->

		<!-- #ifdef MP-WEIXIN || MP-QQ -->
		<payments-by-wx :orderId="orderId"></payments-by-wx>
		<!-- #endif -->

		<!-- #ifdef APP-PLUS -->
		<payments-by-app :orderId="orderId"></payments-by-app>
		<!-- #endif -->

		<!-- #ifdef MP-TOUTIAO -->
		<payments-by-tt :orderId="orderId"></payments-by-tt>
		<!-- #endif -->
	</view>
</template>

<script>
	// #ifdef H5
	import paymentsByH5 from '@/components/payments/paymentsByH5.vue';
	// #endif

	// #ifdef MP-WEIXIN || MP-QQ
	import paymentsByWx from '@/components/payments/paymentsByWx.vue';
	// #endif

	// #ifdef APP-PLUS
	import paymentsByApp from '@/components/payments/paymentsByApp.vue';
	// #endif

	// #ifdef MP-TOUTIAO
	import paymentsByTt from '@/components/payments/paymentsByTt.vue';
	// #endif
	import {
		order
	} from '@/config/mixins.js';
	export default {
		mixins: [order],
		components: {
			// #ifdef H5
			paymentsByH5,
			// #endif
			// #ifdef MP-WEIXIN || MP-QQ
			paymentsByWx,
			// #endif
			// #ifdef APP-PLUS
			paymentsByApp,
			// #endif
			// #ifdef MP-TOUTIAO
			paymentsByTt
			// #endif
		},
		onLoad(e) {
			this.orderId = e.order_id;
			this.type = e.type;
			this.getdetail();
		},
		data() {
			return {
				orderId: '',
				type: '',
				order: {}
			};
		},
		mounted() {
			if (window.location.hash && window.location.href.indexOf("?#") < 0) {
				window.location.href = window.location.href.replace("#", "?#");
			}
		},
		methods: {
			getdetail() {
				this.$api
					.order_detail({
						order_id: this.orderId
					})
					.then(res => {
						if (res.code) {
							this.order = res.data;
							if (this.type == 'success') {
								if (res.data.test_id) {
									this.$common.navigateTo(this.$ph.test + `?test_id=${res.data.test_id}`)
								} else {
									this.$common.errorToShow('支付失败')
								}
							}

						}
					});
			}
		}
	};
</script>

<style>
	page {
		background-color: #f4f6f8;
	}
</style>
